// PLUGIN: IMAGE (MODIFIED)

(function (Popcorn) {

/**
 * Images popcorn plug-in (modified)
 * Shows an image element
 * Options parameter will need a start, end, target and src.
 * Start is the time that you want this plug-in to execute
 * End is the time that you want this plug-in to stop executing 
 * Target is the id of the document element that the iframe needs to be attached to, 
 * this target element must exist on the DOM
 * Src is the url of the image that you want to display
 *
 * Example:
   var p = Popcorn('#video')
      .image({
        start: 5, // seconds
        end: 15, // seconds
        src: 'http://www.drumbeat.org/sites/default/files/domain-2/drumbeat_logo.png',
        target: 'imagediv'
      })
 *
 */
  Popcorn.plugin("image", {
      _setup: function(options) {
        options.img = document.createElement("img");
        options.img.src = options.src;
        options.img.style.display = "none";
        if (document.getElementById(options.target)) {
          document.getElementById(options.target).appendChild(options.img);
        }
      },
      start: function(event, options) {
        options.img.style.display = "block";
      },
      end: function(event, options) {
        options.img.style.display = "none";
      },
      _teardown: function(options) {
        document.getElementById(options.target) && document.getElementById(options.target).removeChild(options.img);
      }
  });
})(Popcorn);
